package com.sms.gui;

import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Point;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;

import com.sms.gui.actions.CancelAction;
import com.sms.gui.actions.OkAction;
import com.sms.util.ResourcesHandler;

public class SettingsDialog extends JDialog {

    private static final long serialVersionUID = 1L;
    private JTextField userField, passwordField;

    public SettingsDialog(Frame f) {
        super(f, "Settings");
        setLocation(new Point(f.getLocation().x + f.getWidth() / 2,
                f.getLocation().y + f.getHeight() / 2));
        setResizable(false);
        setMinimumSize(new Dimension(250, 60));
        setLayout(new GridLayout(3, 2, 10, 10));
        add(new JLabel("Username:"));
        add(userField = new JTextField(ResourcesHandler.getUsername()));
        add(new JLabel("Password:"));
        add(passwordField = new JTextField(ResourcesHandler.getPassword()));
        add(new JButton(new CancelAction(this)));
        add(new JButton(new OkAction(this)));
        pack();
    }

    public JTextField getUserField() {
        return userField;
    }

    public JTextField getPasswordField() {
        return passwordField;
    }
}